from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select
import time

# 基类
class Base():
    # 初始化驱动
    def __init__(self,driver):
        self.driver=driver

    # 封装网址
    def open_url(self,url):
        self.driver.get(url)

    # 封装定位
    def find_element(self,loc):
        self.driver.find_element(*loc)

    # 封装点击事件
    def click(self,loc):
        self.driver.find_element(loc).click()

    # 封装输入
    def send_keys(self,loc,info):
        self.driver.find_element(loc).send_keys(info)

    # 封装frame
    def frame(self,loc):
        self.driver.switch_to.frame(self.find_element(loc))

    # 封装切换窗口
    def window(self):
        self.driver.switch_to.window(self.driver.window_handles[-1])

    # 封装滚动条
    def scrollTo(self,x):
        self.driver.execute_script(f'window scrollTo(0,{x})')


